home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cuj1008.zip / RYAN1.LIS < prev    next >
File List  |  1992-04-08  |  1KB  |  61 lines

  1.   
  2. -----------------------------------------------------------------
  3.                             LISTING I
  4.                INKEY FUNCTION FOR USE WITH VAX/VMS
  5.  
  6. #include descrip
  7.  
  8. #define  DEV_NAM     "MYTERM"
  9. #define  DEV_NAM_LEN 6
  10.  
  11. char inkey(short int chan)
  12. {
  13.    char ch;
  14.    unsigned int stat;
  15.      
  16.    stat = sys$qio(0,chan,113,0,0,0,&ch,1,0,0,0,0);
  17.    if ( stat != 1 ) return -1; return ch;
  18. }
  19.  
  20.  
  21.  
  22. main()
  23. {
  24.    struct dsc$descriptor symbol, result;
  25.    short int chan;
  26.    unsigned int stat;
  27.    unsigned short int reslen;
  28.    int table = 2;
  29.    char c, symname[32] = DEV_NAM, resname[128];
  30.  
  31.    symbol.dsc$w_length  = DEV_NAM_LEN;
  32.    symbol.dsc$b_dtype   = DSC$K_DTYPE_T;
  33.    symbol.dsc$b_class   = DSC$K_CLASS_S;
  34.    symbol.dsc$a_pointer = &symname;
  35.  
  36.    result.dsc$w_length  = 128;
  37.    result.dsc$b_dtype   = DSC$K_DTYPE_T;
  38.    result.dsc$b_class   = DSC$K_CLASS_S;
  39.    result.dsc$a_pointer = &resname;
  40.  
  41.    stat = lib$get_symbol(&symbol,&result,&reslen,&table);
  42.    if ( stat != 1 ) exit( stat );
  43.    resname[reslen] = '\0';
  44.    printf("%s",resname);
  45.  
  46.    result.dsc$w_length  = reslen;
  47.  
  48.    stat = sys$assign(&result,&chan,0,0);
  49.    if ( stat != 1 )
  50.    {
  51.       printf("error assigning channel\n");
  52.       exit(stat);
  53.    }
  54.  
  55.    while ((c = inkey(chan)) != -1) printf("%c,%d\n",c,c);
  56.  
  57. }
  58.  
  59.  
  60.  
  61.